package com.qf.controller.advice;

import com.qf.exce.MyBaseException;
import com.qf.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/*
 *@Description:异常处理器
 *@author:刘哥
 *@Date:86180 2022/8/31 20:05
 */
@RestControllerAdvice
public class ControllerAdvice {
    /**
     * 异常处理器
     * @return 自定义返回值
     */
    @ExceptionHandler(
            MyBaseException.class
    )
    public Result MyException(MyBaseException baseException){
        baseException.printStackTrace();
        return Result.getResult(baseException.getCode(),baseException.getMessage());
    }
}
